<?php
/**
 * @version			$Id$
 * @author			Richard Asp
 * @package			Joomla
 * @subpackage		gnudoor
 * @copyright		(C) 2010 gnudoor LLC
 * @license      GNU/GPL, see LICENSE.php
 * Joomla! is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * See COPYRIGHT.php for copyright notices and details.
 */

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );

class GnudoorHelperGnudoorHelper extends JComponentHelper
{
		function __construct() {
            jimport( 'joomla.utilities.utility' );
        }
		function _sendMail2($subject, $body, $addresses = array()) {
			global $mainframe;

			$mailer =& JFactory::getMailer();
			// Set a sender
		    $config = new JConfig();
		    $from = $config->mailfrom;
		    $fromname = $config->fromname;

			$sender = array( 
			    $from,
			    $fromname );
			 
			$mailer->setSender($sender);
			//  Set the receipent
//			$user =& JFactory::getUser();
//			$usersemail = $user->email;
//			$recipient = array($addresses);
						 
			$mailer->addRecipient($addresses);
			//  Create the email
//			$body   = "Your body string\nin double quotes if you want to parse the \nnewlines etc";
			$mailer->setSubject($subject);
			//  if you want an HTML email use the following
			//  code:
//			$body   = '<h2>Our mail</h2>'
//			    . '<div>A message to our dear readers'
//			    . '<img src="cid:logo_id" alt="logo"/></div>';
//			$mailer->isHTML(true);
			$mailer->setBody($body);
			// Optional file attached
			// $mailer->addAttachment(PATH_COMPONENT.DS.'assets'.DS.'document.pdf');
			//  Send the email			
			$send =& $mailer->Send();
			if ( $send !== true ) {
			    echo 'Error sending email: ' . $send->message;
			} else {
			    echo 'Mail sent';
			}
			
		}
        function _sendMail($subject, $body, $recipient) {
			$from = 'test@example11.com';
			$fromname = 'richard';
		//	$recipient = 'richard@example11.com';
		//	$subject = 'Test Test Email';
		//	$body = 'This is a test email to see if this method works';
        	JUtility::sendMail($from, $fromname, $recipient, $subject, $body, $mode=0, $cc=null, $bcc=null, $attachment=null, $replyto=null, $replytoname=null);
        }
}
?>